package flex.persistence.criteria {
	import flex.persistence.criteria.criteriaQuery.Case;
	import flex.persistence.criteria.criteriaQuery.Coalesce;

	import flex.persistence.criteria.criteriaQuery.SimpleCase;
	import flex.persistence.criteria.criteriaQuery.Trimspec;
 
	public interface CriteriaBuilder {
		
		/** 
		 * abs(x:Expression):Expression
		 * Create an expression that returns the absolute value of its argument.
		 */
		function abs(x:Expression):Expression;
	
		/**
		 * all(subquery:Subquery):Expression
		 * Create an all expression over the subquery results.
		 */
		function all(subquery:Subquery):Expression;
		
		/**
		 * and(x:Expression, y:Expression):Predicate
		 * Create a conjunction of the given boolean expressions.
		 */
		function and(x:Expression, y:Expression):Predicate; 
		
		/**
		 * Predicate and(Predicate... restrictions)
		 * Create a conjunction of the given restriction predicates.
		 */
		// function and(... restriction):Predicate;
		
		/**
		 * any(subquery:Subquery):Expression
		 * Create an any expression over the subquery results.
		 */
		function any(subquery:Subquery):Expression;

		/**
		 * asc(x:Expression):Order
		 * Create an ordering by the ascending value of the expression.
		 */
		function asc(x:Expression):Order;
		
		/**	
		 * avg(x:Expression):Expression
		 * Create an aggregate expression applying the avg operation.
		 */
		function avg(x:Expression):Expression;
		
		/**
		 * between(v:Expression, x:*, y:*):Predicate
		 * Create a predicate for testing whether the first argument is between the second and third arguments in value.
		 */
		function between(v:Expression, x:*, y:*):Predicate;
	
		/**
		 * coalesce():Coalesce;
		 * Create a coalesce expression.
		 */
		function coalesce():Coalesce;
	
		/**
		 * coalesceExpression(x:Expression, y:Expression):Expression
		 * Create an expression that returns null if all its arguments evaluate to null, and the value of the first non-null argument otherwise.
		 */
		function coalesceExpression(x:Expression, y:Expression):Expression;
		
		/**
		 * coalesceValue(x:Expression, y:*):Expression
		 * Create an expression that returns null if all its arguments evaluate to null, and the value of the first non-null argument otherwise.
		 */
		function coalesceValue(x:Expression, y:*):Expression;
			
		/**
		 * concat(x:*, y:*):Expression
		 * Create an expression for concatenation.
		 */
		function concat(x:*, y:*):Expression;
		
		/**
		 * conjunction():Predicate
		 * Create a conjunction (with zero conjuncts).
		 */
		function conjunction():Predicate;

		/**
		 * count(x:Expression):Expression
		 * Create an aggregate expression applying the count operation.
		 */
		function count(x:Expression):Expression;
		
		/**
		 * countDistinct(x:Expression):Expression
		 * Create an aggregate expression applying the count distinct operation.
		 */
		function countDistinct(x:Expression):Expression;
		
		/**
		 * createQuery(resultClass:Class):CriteriaQuery
		 * Create a CriteriaQuery object.
		 */
		function createQuery(resultClass:Class):CriteriaQuery;
		
		/**
		 * createTupleQuery():CriteriaQuery
		 * Create a CriteriaQuery object that returns a tuple of objects as its result.
		 */
		function createTupleQuery():CriteriaQuery;
		
		/**
		 * currentDate():Expression
		 * Create expression to return current date.
		 */
		function currentDate():Expression;
	
		/**
		 * currentTime():Expression
		 * Create expression to return current time.
		 */
		function currentTime():Expression;
		
		/**
		 * currentTimeStamp():Expression
		 * Create expression to return current timestamp.
		 */
		function currentTimeStamp():Expression;
		
		/**
		 * desc(expr:Expression):Order
		 * Create an ordering by the descending value of the expression.
		 */
		function desc(expr:Expression):Order;
		
		/**
		 * diff(x:*, y:*):Expression
		 * Create an expression that returns the difference between its arguments.
		 */
		function diff(x:*, y:*):Expression;
		
		/**
		 * disjunction():Predicate
		 * Create a disjunction (with zero disjuncts).
		 */
		function disjunction():Predicate;
		
		/**
		 * equal(x:Expression, y:*):Predicate
		 * Create a predicate for testing the arguments for equality.
		 */
		function equal(x:Expression, y:*):Predicate;
		
		/**
		 * exists(subquery:Subquery):Predicate
		 * Create a predicate testing the existence of a subquery result.
		 */
		function exists(subquery:Subquery):Predicate;
		
		/**
		 * func(name:String, type:Class, ... args):Expression
		 * Create an expression for the execution of a database function.
		 */ 
		function func(name:String, type:Class, ... args):Expression;
		
		/**
		 * ge(x:Expression, y:*):Predicate
		 * Create a predicate for testing whether the first argument is greater than or equal to the second.
		 */
		function ge(x:Expression, y:*):Predicate;
		
		/**
		 * greaterThan(x:Expression, y:*):Predicate
		 * Create a predicate for testing whether the first argument is greater than the second.
		 */
		function greaterThan(x:Expression, y:*):Predicate;
		
		/**
		 * greaterThanOrEqualTo(x:Expression, y:*):Predicate
		 * Create a predicate for testing whether the first argument is greater than or equal to the second.
		 */
		function greaterThanOrEqualTo(x:Expression, y:*):Predicate;
		
		/**
		 * greatest(x:Expression):Expression
		 * Create an aggregate expression for finding the greatest of the values (strings, dates, etc).
		 */
		function greatest(x:Expression):Expression;
		
		/**
		 * gt(x:Expression, y:*):Predicate
		 * Create a predicate for testing whether the first argument is greater than the second.
		 */
		function gt(x:Expression, y:*):Predicate;
		
		/**
		 * inValues(expression:Expression):In
		 * Create predicate to test whether given expression is contained in a list of values.
		 */
	//	function inValues(expression:Expression):In;
		
		/**
		 * isEmpty(collection:Expression):Predicate
		 * Create a predicate that tests whether a collection is empty. 
		 */
		function isEmpty(collection:Expression):Predicate;
		
		/**
		 * isFalse(x:Boolean):Predicate
		 * Create a predicate testing for a false value. 
		 */
		function isFalse(x:Boolean):Predicate;
		
		/**
		 * isMember(elem:*, collection:Expression):Predicate
		 * Create a predicate that tests whether an element is a member of a collection.
 		 */
		function isMember(elem:*, collection:Expression):Predicate;
		
		/**
		 * isNotEmpty(collection:Expression):Predicate
		 * Create a predicate that tests whether a collection is not empty. 
		 */
		function isNotEmpty(collection:Expression):Predicate;
		
		/**
		 * isNotMember(elem:*, collection:Expression):Predicate
		 * Create a predicate that tests whether an element is not a member of a collection. 
		 */
		function isNotMember(elem:*, collection:Expression):Predicate;
	
		/**
		 * isNotNull(x:Expression):Predicate
		 * Create a predicate to test whether the expression is not null. 
		 */
		function isNotNull(x:Expression):Predicate;
		
		/**
		 * isNull(x:Expression):Predicate
		 * Create a predicate to test whether the expression is null.
		 */ 
		function isNull(x:Expression):Predicate;
		
		/**
		 * isTrue(x:Boolean):Predicate
		 * Create a predicate testing for a true value. 
		 */		
		function isTrue(x:Boolean):Predicate;
		
		/**
		 * keys(map:Array):Expression
		 * Create an expression that returns the keys of a map. 
		 */
		function keys(map:Array):Expression;
		
		/**
		 * le(x:Expression, y:*):Predicate
		 * Create a predicate for testing whether the first argument is less than or equal to the second.
		 */
		function le(x:Expression, y:*):Predicate;
		
		/**
		 * least(x:Expression):Expression
		 * Create an aggregate expression for finding the least of the values (strings, dates, etc).
		 */
		function least(x:Expression):Expression;		
		
		/**
		 * length(x:Expression):Expression
		 * Create expression to return length of a string. 
		 */
		function length(x:Expression):Expression;
		
		/**
		 * lessThan(x:Expression, y:*):Predicate
		 * Create a predicate for testing whether the first argument is less than the second.
		 */
		function lessThan(x:Expression, y:*):Predicate;
		
		/**
		 * lessThanOrEqualTo(x:Expression, y:*):Predicate
		 * Create a predicate for testing whether the first argument is less than or equal to the second.
		 */
		function lessThanOrEqualTo(x:Expression, y:*):Predicate;
		
		/**
		 * like(x:String, expression:Expression):Predicate
		 * Create a predicate for testing whether the expression satisfies the given pattern.
		 */
		//function like(x:String, pattern:*, escapeChar:*):Predicate;
		function like(x:String, expression:Expression):Predicate;
		
		/**
		 * literal(value:*):Expression
		 * Create an expression for a literal. 
		 */
		function literal(value:*):Expression;
		
		/**
		 * locate(x:Expression, pattern:*, from:*):Expression
		 * Create expression to locate the position of one string within another, returning position of first character if found.
		 */
		function locate(x:Expression, pattern:*, from:*):Expression;
		
		/**
		 * lower(x:Expression):Expression
		 * Create expression for converting a string to lowercase. 
		 */
		function lower(x:Expression):Expression;
		
		/**
		 * lt(x:Expression, y:*):Predicate
		 * Create a predicate for testing whether the first argument is less than the second.
		 */
		function lt(x:Expression, y:*):Predicate;
		
		/**
		 * max(x:Expression):Expression
		 * Create an aggregate expression applying the numerical max operation.
		 */
		function max(x:Expression):Expression;
		
		/**
		 * min(x:Expression):Expression
		 * Create an aggregate expression applying the numerical min operation.
		 */ 		
		function min(x:Expression):Expression;
		
		/**
		 * mod(x:*, y:*):Predicate
		 * Create an expression that returns the modulus of its arguments.
		 */
		function mod(x:*, y:*):Predicate;
		
		/**
		 * neg(x:Expression):Expression
		 * Create an expression that returns the arithmetic negation of its argument. 
		 */
		function neg(x:Expression):Expression;
		
		/**
		 * not(restriction:Expression):Predicate
		 * Create a negation of the given restriction.
		 */
		function not(restriction:Expression):Predicate;
		
		/**
		 * notEqual(x:Expression, y:*):Predicate
		 * Create a predicate for testing the arguments for inequality.
		 */
		function notEqual(x:Expression, y:*):Predicate;
		
		/**
		 * notLike(x:String, pattern:*, escapeChar:*):Predicate
		 * Create a predicate for testing whether the expression does not satisfy the given pattern. 
		 */
		function notLike(x:String, pattern:*, escapeChar:*):Predicate;
		
		/**
		 * nullif(x:Expression, y:*):Expression
		 * Create an expression that tests whether its argument are equal, returning null if they are and the value of the first expression if they are not.
		 */		  
		function nullif(x:Expression, y:*):Expression;
		
		/**
		 * nullLiteral(resultClass:Class):Expression
		 * Create an expression for a null literal with the given type.
		 */ 
		function nullLiteral(resultClass:Class):Expression;
		
		/**
		 * or(x:Expression, y:Expression):Predicate
		 * Create a disjunction of the given restriction predicates.		  
		 */
		function or(x:Expression, y:Expression):Predicate;
		
		/**
		 * parameter(paramClass:Class, name:String=null):ParameterExpression
		 * Create a parameter expression with the given name. 
		 */
		function parameter(paramClass:Class, name:String=null):ParameterExpression;
		
		/**
		 * prod(x:*, y:*):Expression
		 * Create an expression that returns the product of its arguments.		 
		 */
		function prod(x:*, y:*):Expression;
		
		/**
		 * quot(x:*, y:*):Expression
		 * Create an expression that returns the quotient of its arguments.
		 */
		function quot(x:*, y:*):Expression;
		
		/**
		 * selectCase():Case
		 * Create a general case expression.
		 */
		function selectCase():Case;
		
		/**
		 * selectSimpleCase(expression:Expression):SimpleCase
		 * Create a simple case expression.
		 */		
		function selectSimpleCase(expression:Expression):SimpleCase;
	
		/**
		 * size(collection:*):Expression
		 * Create an expression that tests the size of a collection.
		 */
		function size(collection:*):Expression;
		
		/**
		 * some(subquery:Subquery):Expression
		 * Create a some expression over the subquery results.
		 */
		function some(subquery:Subquery):Expression;
	
		/**
		 * sqrt(x:Expression):Expression
		 * Create an expression that returns the square root of its argument.
		 */
		function sqrt(x:Expression):Expression;
		
		/**
		 * substring(x:Expression, from:*, len:*=null):Expression
		 * Create an expression for substring extraction.
		 */
		function substring(x:Expression, from:*, len:*=null):Expression;
		
		/**
		 * sum(x:*, y:*=null):Expression
		 * Create an expression that returns the sum of its arguments.
		 */
		function sum(x:*, y:*=null):Expression;
		
		/**
		 * sumAsDouble(x:Expression):Expression
		 * Create an aggregate expression applying the sum operation to a Float-valued expression, returning a Double result.
		 */
		function sumAsDouble(x:Expression):Expression;
		
		/**
		 * sumAsLong(x:Expression):Expression
		 * Create an aggregate expression applying the sum operation to an Integer-valued expression, returning a Long result.
		 */
		function sumAsLong(x:Expression):Expression;
		
		/**
		 * toBigDecimal(number:Expression):Expression
		 * Typecast.
		 */
		function toBigDecimal(number:Expression):Expression;
	
		/**
		 * toBigInteger(number:Expression):Expression
		 * Typecast.
		 */
		function toBigInteger(number:Expression):Expression;
		
		/**
		 * toDouble(number:Expression):Expression
		 * Typecast.
		 */
		function toDouble(number:Expression):Expression;
		
		/**
		 * toFloat(number:Expression):Expression
		 * Typecast.
		 */
		function toFloat(number:Expression):Expression;
		
		/**
		 * toInteger(number:Expression):Expression
		 * Typecast.
		 */
		function toInteger(number:Expression):Expression;
		
		/**
		 * toLong(number:Expression):Expression
		 * Typecast.
		 */
		function toLong(number:Expression):Expression;
		
		/**
		 * toString(character:Expression):Expression
		 * Typecast.
		 */
		function toString(character:Expression):Expression;
		
		/**
		 * trim(x:Expression, ts:Trimspec=null, t:String=null):Expression
		 * Create expression to trim blanks from both ends of a string.
		 */
		function trim(x:Expression, ts:Trimspec=null, t:String=null):Expression; 

		/**
		 * upper(x:Expression):Expression
		 * Create expression for converting a string to uppercase. 
		 */
		function upper(x:Expression):Expression;
		
		/**
		 * values(map:Array):Expression
		 * Create an expression that returns the values of a map. 
		 */
		function values(map:Array):Expression;
	}
}
